<?php 
include_once(''.P.'/public/header.html');
?>

<script type="text/javascript" src="res/bootstrapplugin/jquery-bootstable.js"></script>


<script>
function initbody(){
	<?php if($type=='upg'){?>
	
	table = $('#viewshow').bootstable({
		url:'index.php?m=cog&a=upgdata&d=plat',method:'get',
		cellurl:'abc',fanye:false,
		columns:[{
			text:'名称',dataIndex:'name'
		},{
			text:'说明',dataIndex:'explain',align:'left'
		},{
			text:'更新时间',dataIndex:'updatedt'
		},{
			text:'价格',dataIndex:'price',renderer:function(v){
				var s='<font color=#ff6600>免费</font>';
				if(v>0)s=v+'元';
				return s;
			}
		},{
			text:'详情',dataIndex:'view'
		},{
			text:'操作',dataIndex:'opt',align:'left',renderer:function(v,d){
				if(d.isaz=='0')return '<font color=#888888>无需安装</font>';
				var s='';
				if(v==1)s='<font color=green>已安装</font> <a href="?m=cog&d=plat&a=upg&sid='+jm.base64encode(d.id)+'">文件</a>';
				if(v==2)s='<a class="webbtn" href="?m=cog&d=plat&a=upg&sid='+jm.base64encode(d.id)+'" class="webbtn" type="button" style="background:#800000">升级</a>';
				if(v==0)s='<a class="webbtn" href="?m=cog&d=plat&a=upg&sid='+jm.base64encode(d.id)+'">安装</a>';
				return '<span id="msgshow'+d.id+'">'+s+'</span>';
			}
		}]	
	});
	<?php }?>
}
function save(o1){
	var da = js.getformdata();
	da.type = '<?=$type?>';
	js.setmsg('保存中...');
	o1.disabled=true;
	js.ajax({
		type:'post',
		url:'?m=cog&a=savecheck&d=plat',
		data:da,
		success:function(res){
			o1.disabled=false;
			if(res=='ok'){
				js.setmsg('保存成功','green');
			}else{
				js.setmsg(res);
			}
		}
	});
}
</script>
<style>
.caidan{padding:10px;text-align:left;border-bottom:1px #eeeeee solid;cursor:pointer}
.caidan:hover{background-color:rgba(0,0,0,0.05)}
.caidan.active{background-color:rgba(0,0,0,0.06)}
</style>
</head>

<body>

<?php 
include_once(''.P.'/public/top_plat.html');
?>

<div align="center">

<div style="width:<?=$maxwidth?>;margin:20px 0px" align="left">
	<div style="color:#cccccc">
		<a href="?m=index&d=plat" class="zhu"><?=lang('plat.home')?></a> &gt;
		<a href="" class="zhu"><?=lang('plat.cogtitle')?></a>
	</div>
	
	<div class="mainbody">
	
	<table width="100%">
	<tr valign="top">
	<td>
	<div style="width:180px;background:#f9f9f9;min-height:500px;border-right:1px #f1f1f1 solid">
		
		<div class="caidan<?php if(isempt($type))echo ' active';?>">◇ <a href="?m=cog&d=plat">系统设置</a></div>
		<div class="caidan<?php if($type=='upg')echo ' active';?>">◇ <a href="?m=cog&type=upg&d=plat">系统升级</a></div>
		<div class="caidan<?php if($type=='server')echo ' active';?>">◇ <a href="?m=cog&type=server&d=plat">服务端设置</a></div>
		<div class="caidan<?php if($type=='sms')echo ' active';?>">◇ <a href="?m=cog&type=sms&d=plat">短信设置</a></div>
	
		
	</div>
	</td>
	
	<td width="90%">
	
	<?php if(isempt($type)){?>
	<div style="padding:30px 30px">
		<form name="myform">
		<table>
		<tr><td align="right" style="color:gray">系统版本：</td>
		<td ><b style="font-size:18px;color:green">高级版</b>
		
		</td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">系统名称：</td><td><input name="title" type="text" value="<?=getconfig('title')?>" style="width:260px" class="input"></td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray"><font color=red>*</font>信呼官网key：</td>
		<td >
		<input placeholder="必须，否则无法升级" type="text" value="<?=$xhrock->getxings(getconfig('xinhukey'))?>" name="xinhukey" style="width:260px" class="input">
		<span style="color:#aaaaaa;">看帮助获取</span>
		</td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">是否开放注册：</td>
		<td>
		<select name="regbool" style="width:260px" class="input">
		<option value="0">不开放</option>
		<option value="1"<?php if(getconfig('regbool')=='1')echo' selected';?>>开放</option>
		</select></td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">文档预览方式：</td>
		<td>
		<select name="officebj_fan" style="width:260px" class="input">
		<option value="0">编辑平台WPS</option>
		<option value="1"<?php if(getconfig('officebj_fan')=='1')echo' selected';?>>编辑平台onlyoffice</option>
		<option value="4"<?php if(getconfig('officebj_fan')=='4')echo' selected';?>>信呼官网转PDF预览服务</option>
		<option value="2"<?php if(getconfig('officebj_fan')=='2')echo' selected';?>>微软服务(需要域名80端口)</option>
		<option value="3"<?php if(getconfig('officebj_fan')=='3')echo' selected';?>>明道服务(需要域名80端口)</option>
		</select></td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">编辑平台key：</td><td>
		<input placeholder="从文档编辑平台上获取" type="text" value="<?=$xhrock->getxings(getconfig('officebj_key'))?>" name="officebj_key" style="width:260px" class="input">
		<span style="color:#aaaaaa;">从编辑平台获取</span>
		</td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">系统主题色：</td><td><input name="apptheme" type="text" value="<?=getconfig('apptheme')?>" style="width:260px" maxlength="7" placeholder="#开头的RGB格式如：#336699" class="input"></td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right"></td><td>
		<button type="button" onClick="save(this)" style="padding:8px 20px;border-radius:5px" class="webbtn" >保存</button>&nbsp;<span id="msgview"></span>
		</td></tr>
		
		</table>
		<div style="color:#aaaaaa;margin-top:10px">更多请到配置文件：webmain/webmainConfig.php下设置</div>
		</form>
	</div>
	<?php }?>
	
	
	
	<?php if($type=='upg'){?>
	<script type="text/javascript" src="res/bootstrapplugin/jquery-bootstable.js"></script>
	
	<div style="padding:10px">
		<div style="padding:5px 0px"><button onClick="table.reload()" class="webbtn" type="button" style="border-radius:5px">刷新</button></div>
		<div class="blank10"></div>
		<div id="viewshow"></div>
		<div style="color:#aaaaaa;margin-top:5px">请根据自己情况安装升级。</div>
	</div>
	<?php }?>
	
	
	
	
	<?php if($type=='server'){?>
	<script>
	function shezhis(){
		js.prompt('请输入您服务器IP', function(jg,txt){
			if(jg=='yes' && txt){
				form('server_host').value='ws://'+txt+':6552/';
				form('server_push').value='http://127.0.0.1:6553/';
				form('server_recid').value='reimplat';
			}
		},'服务端设置');
	}
	function texttong(){
		var val = form('server_host').value;
		if(!val){
			js.msgerror('请先设置');
			shezhis();
			return;
		}
		var url = val.replace('ws','http');
		js.confirm('弹出页面显示“<b>Upgrade Required</b>”说明可以用，打不开就不能用。',function(jg){
			if(jg=='yes')js.open(url);
		});
	}
	function texttongs(){
		var val = form('server_push').value;
		if(!val){js.msgerror('请先设置');shezhis();return;}
		js.loading('测试中...');
		js.ajax({
			url:'?a=textpush&m=cog&d=plat',
			dataType:'json',
			success:function(ret){
				if(ret.success){
					js.msgok(ret.data);
				}else{
					js.msgerror(ret.msg);
				}
			}
		});
	}
	</script>
	<div style="padding:30px 30px">
		<form name="myform">
		
		<table>
		
		<tr><td align="right" style="color:gray"></td><td>
		
		<input type="button" value="快速设置" onclick="shezhis()" style="background:gray;border-radius:5px" class="webbtn">
		
		</td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">通信地址：</td><td><input name="server_host" type="text" value="<?=getconfig('server_host')?>" style="width:260px" class="input"></td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">服务端推送地址：</td>
		<td >
		<input type="text" value="<?=getconfig('server_push')?>" name="server_push" style="width:260px" class="input">
		</td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">recID号：</td>
		<td >
		<input type="text" value="<?=getconfig('server_recid')?>" name="server_recid" style="width:260px" class="input">
		</td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">撤回时间(分钟)：</td>
		<td >
		<input type="text" value="<?=getconfig('server_chehui')?>" type="number" placeholder="0不可撤回" name="server_chehui" style="width:260px" class="input">
		</td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right"></td><td>
		<button type="button" onClick="save(this)" style="padding:8px 20px;border-radius:5px" class="webbtn" >保存</button>&nbsp;
		<a href="javascript:;" class="zhu" onclick="texttong()">测试通信地址</a>&nbsp;
		<a href="javascript:;" class="zhu" onclick="texttongs()">测试推送地址</a>&nbsp;
		<span id="msgview"></span>
		</td></tr>
		
		</table>
		</form>
	</div>
	<?php }?>
	
	
	<?php if($type=='sms'){?>
	<div style="padding:30px 30px">
		<form name="myform">
		<table>

		<tr><td align="right" style="color:gray">短信服务平台：</td>
		<td>
		<select name="sms_provider" style="width:260px" class="input">
		<option value="">信呼短信服务</option>
		<option value="smsali"<?php if(getconfig('sms_provider')=='smsali')echo' selected';?>>阿里云短信服务</option>
		<option value="smsmy"<?php if(getconfig('sms_provider')=='smsmy')echo' selected';?>>我的短信服务</option>
		</select></td></tr>
		<tr><td height="10"></td></tr>

		
		<tr><td align="right" style="color:gray">短信签名编号：</td><td><input name="sms_sign" type="text" value="<?=getconfig('sms_sign')?>" style="width:260px" placeholder="默认【REIM通信平台】，可不填" class="input"></td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">短信验证码模板编号：</td><td><input name="sms_codetpl" type="text" value="<?=getconfig('sms_codetpl')?>" style="width:260px" placeholder="默认defyzm，可不填" class="input"></td></tr>
		<tr><td height="10"></td></tr>
		
		
		<tr><td align="right"></td><td>
		<button type="button" onClick="save(this)" style="padding:8px 20px;border-radius:5px" class="webbtn" >保存</button>&nbsp;<span id="msgview"></span>
		</td></tr>
		
		</table>
		</form>
	</div>
	<?php }?>
	
	
	</td>
	</tr>	
	</table>


	</div>
</div>



<?php 
include_once(''.P.'/public/footer.html');
?>
</div>

</body>
</html>